import request from '@/utils/request'

// 创建文章
// 创建文章
export function createArticle(data) {
  return request({
    url: '/app/article/create',
    method: 'post',
    data: data
  })
}

// 更新文章
export function updateArticle(data) {
  return request({
    url: '/app/article/update',
    method: 'put',
    data: data
  })
}

// 删除文章
export function deleteArticle(id) {
  return request({
    url: '/app/article/delete?id=' + id,
    method: 'delete'
  })
}

// 获得文章
export function getArticle(id) {
  return request({
    url: '/app/article/get/mobile?id=' + id,
    method: 'get'
  })
}

// 获得文章分页
export function getArticlePage(params) {
  return request({
    url: '/app/article/page',
    method: 'post',
    data: params
  })
}
// 导出文章 Excel
export function exportArticleExcel(params) {
  return request({
    url: '/app/article/export-excel',
    method: 'get',
    params,
    responseType: 'blob'
  })
}

// 创建文章点赞
export function createArticleLike(data) {
  return request({
    url: '/app/article-like/create',
    method: 'post',
    data: data
  })
}

// 更新文章点赞
export function updateArticleLike(data) {
  return request({
    url: '/app/article-like/update',
    method: 'put',
    data: data
  })
}

// 删除文章点赞
export function deleteArticleLike(id) {
  return request({
    url: '/app/article-like/delete?id=' + id,
    method: 'delete'
  })
}

// 获得文章点赞
export function getArticleLike(id) {
  return request({
    url: '/app/article-like/get?id=' + id,
    method: 'get'
  })
}

// 获得文章点赞分页
export function getArticleLikePage(params) {
  return request({
    url: '/app/article-like/page',
    method: 'post',
    data: params
  })
}
// 导出文章点赞 Excel
export function exportArticleLikeExcel(params) {
  return request({
    url: '/app/article-like/export-excel',
    method: 'get',
    params,
    responseType: 'blob'
  })
}

export function getArticlePublishTrend() {
  return request({
    url: '/app/article/trend',
    method: 'get'
  })
}

export function getArticleCount() {
  return request({
    url: '/app/article/count',
    method: 'get'
  })
}
